<?php
error_reporting(E_ALL | ~E_NOTICE);
session_start();

//定义应用程序路径 结尾没有/
define ('APP', dirname(__FILE__));

require_once APP . '/frame/Route.php';    //路由模块
require_once FRAME_ROOT_PATH . '/db/Mysql.php';               //数据库
require_once FRAME_ROOT_PATH . '/cache/FileCache.php';        //一个用文件缓存模块

//配置文件 
require_once APP . '/application/configs/application.php';

Mysql::setInstance("default", $cfg['db']['host'], $cfg['db']['user'], $cfg['db']['password'], $cfg['db']['name'], $cfg['db']['charset']);
FileCache::setInstance("default", APP . '/cache');

if ($cfg ['debug']) {
    Mysql::getInstance()->setProfiler(true);
}

//加载路由，这里支持多模块和自定义路由
$route = new Route ( array (
                            'default' => APP . "/application/controllers",//默认模块
                            'admin'   => APP . "/application/admincontrollers"//测试的admin模块，这里仅测试，所以路径和默认模块一样
                            ),
                    /**下面是自定义路由，名称=> 配置   可以为空数组**/
                     array (
                             'admincp' => array ('module' => 'admin', 'controller' => 'index', 'action' => 'index')
                            ),
                    /** 是否开启rewrite，影响 url 方法的输出,以及路由模块 **/
                     $cfg ['urlrewrite']
);

//可以自定义参数名称
$route->setModuleKey ('m');
$route->setControllerKey ('c');
$route->setActionKey ('a');

header("Content-type: text/html; charset=utf-8");

//运行程序
$route->run ();